package com.woniu.order.client;

import com.alipay.api.domain.Goods;
import com.woniu.exception.userexp.YogaException;
import com.woniu.model.*;
import com.woniu.order.Form.AddLeagueClassMarginForm;
import com.woniu.order.Form.AddLeagueClassOrderPeopleForm;
import com.woniu.order.Form.AddPersonalClassMarginForm;
import com.woniu.order.Form.UserAndClassIdForm;
import com.woniu.order.client.model.MemberCard;
import com.woniu.order.dto.ClassTypeDto;
import com.woniu.order.model.*;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;

import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;


import java.util.List;

@Component
@FeignClient(name = "product-server",path = "/product")
public interface ProductClient {


    /**
     * 通过一个商品ID查询一个商品回去
     *
     * @param id ：商品id
     * @return 一个商品
     */

    @GetMapping("/goods/selectGoodsById")
    @ApiOperation(value = "通过一个商品ID查询一个商品回去")
    Result<GoodsDto> byId(@RequestParam("id") Integer id);

    /**
     * 传一个对象，根据id去修改里面的信息
     * 在商城订单里面用了，用于去修改商品的冻结量和数量
     * @param ygoods 商品对象
     * @return
     * @throws
     */

    @PostMapping("/goods/updateByIdGoods")
    @ApiOperation(value = "传一个对象，根据id去修改里面的信息")
    Result updateByIdGoods(@RequestBody Goods ygoods)throws YogaException;

    /**
     * 通过团课Id查一个团课
     *
     * @param id：团课id
     * @return
     */

    @GetMapping("/LeagueClass/ByIdLeagueClass")
    @ApiOperation("通过团课Id查一个团课")
    Result<LeagueClass> ByIdLeagueClass(@RequestParam("id") Integer id);

    /**
     * 新增团课学员
     * @param form
     * @return
     */

    @PostMapping("/LeagueClassOrderPeople/addLeagueClassOrderPeople")
    @ApiOperation("新增团课的用户名单")
    Result<?> addLeagueClassOrderPeople(@RequestBody AddLeagueClassOrderPeopleForm form);

    /**
     * 新增用户的团课余量
     * @param form
     * @return
     */

    @PostMapping("/UserLeagueClassMargin/addLeagueClassMargin")
    @ApiOperation("新增用户的团课余量")
    Result<?> addLeagueClassMargin(@RequestBody AddLeagueClassMarginForm form);

    /**
     * 根据课程id查询排班信息
     * @param courseId
     * @return
     */

    @GetMapping("/LeagueWorkforce/loadLeagueWorkforceByClassId")
    @ApiOperation("根据课程id查询排班信息")
    Result<List<LeagueWorkforce>> loadLeagueWorkforceByClassId(@RequestParam("courseId") Integer courseId);

    /**
     * 根据订单查询余课对象
     * @param orderNum
     * @return
     */

    @GetMapping("/LeagueWorkforce/loadLeagueClassMarginByOrderNum")
    @ApiOperation("根据订单查询余课对象")
    Result<UserPersonalClassMargin> loadLeagueClassMarginByOrderNum(@RequestParam("orderNum") String orderNum);

//    /**
//     * 传私教课ID查询一个私教课回去
//     *
//     * @param id：私教课id
//     * @return
//     * @throws YogaException
//     */
//    @GetMapping("/yPersonalClass/byIdPersonal")
//    @ApiOperation("传私教课ID查询一个私教课回去")
//    public Result<PersonalClass> byIdPersonal(@RequestParam("id") Integer id);

    /**
     * 新增用户的私教余量
     * @param form
     * @return
     */

    @PostMapping("/yUserPersonalClassMargin/addPersonalClassMargin")
    @ApiOperation("新增用户的团课余量")
    Result<?> addPersonalClassMargin(@RequestBody AddPersonalClassMarginForm form);

    /**
     * 传用户id和课程id查询私教课余量
     *
     * @param form
     * @return
     * @throws YogaException
     */

    @PostMapping("/UserPersonalClassMargin/loadPersonalMarginByUserAndClassId")
    @ApiOperation("传用户id和课程id查询私教课余量")
    Result<UserPersonalClassMargin> loadPersonalMarginByUserAndClassId(@RequestBody UserAndClassIdForm form);

    /**
     * 私教课余量减一
     *
     * @param id 私教课余量id
     * @return
     * @throws YogaException
     */

    @PostMapping("/UserPersonalClassMargin/substractPersonalMarginByUserAndClassId")
    @ApiOperation("私教课余量减一")
    Result<?> substractPersonalMarginByUserAndClassId(@RequestBody Integer id);


    /**
     * 加载所有团课对象
     *
     * @return
     * @throws YogaException
     */

    @GetMapping("/LeagueClass/loadAllLeagueClass")
    @ApiOperation("加载所有团课对象")
    Result<List<LeagueClass>> loadAllLeagueClass();

    /**
     * 通过ID查询一个类型回去
     *
     * @param id:一个类型id
     * @return
     * @throws YogaException
     */

    @GetMapping("/ClassType/byId/{id}")
    @ApiOperation(value = "通过ID查询一个类型回去")
    Result<ClassTypeDto> byClassTypeId(@PathVariable("id") Integer id) throws YogaException;

    /**
     * 通过名称加载所有团课对象
     *
     * @return
     * @throws YogaException
     */

    @GetMapping("/LeagueClass/loadLeagueClassByName")
    @ApiOperation("通过名称加载所有团课对象")
    Result<List<LeagueClass>> loadLeagueClassByName(@RequestParam("leagueClassName") String leagueClassName);

    /**
     *
     * @param cardId
     * @return
     */
    @GetMapping("/memberCard/getCardById")
    @ApiOperation("通过会员卡ID查询会员卡")
    Result<MemberCard> getCardById(@RequestParam("cardId") String cardId)throws Exception;
}
